package com.shop2cn.iapi.couponmanage.testcase.old;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;


import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.couponmanage.parameter.BatchInfo;
import com.shop2cn.iapi.couponmanage.parameter.CreateBagBean;
import com.shop2cn.iapi.couponmanage.parameter.CreateCouponBean;
import com.shop2cn.iapi.couponmanage.parameter.createTaskByFileBean;
import com.shop2cn.iapi.couponmanage.service.CreateBagCall;
import com.shop2cn.iapi.couponmanage.service.CreateCouponCall;
import com.shop2cn.iapi.couponmanage.service.createTaskByFileCall;
import com.ymatou.iapi.fileupload.service.UploadCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponShop2cnMCallService;
import com.ymttest.database.model.couponbatch;
import com.ymttest.database.model.couponsendsubtask;
import com.ymttest.database.model.couponsendtask;
import com.ymttest.database.sqlwapper.couponbatchWapper;
import com.ymttest.database.sqlwapper.couponsendsubtaskWapper;
import com.ymttest.database.sqlwapper.couponsendtaskWapper;
/**
*根据用户Id文件创建发券任务
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_createTaskByFile{
	private static createTaskByFileBean bean;
	private static createTaskByFileCall call;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("根据用户Id文件创建发券任务");
	}

	@Before
	public void caseUp() {
		bean=new createTaskByFileBean();
		call=new createTaskByFileCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_createTaskByUserId_001() {
		Logger.start(true,"根据用户Id文件创建发券任务");
		try {
			
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(10);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();

			verifyReturn(1,userIds);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_createTaskByUserId_002() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证userIds-集合总数小于100");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(10);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();

			verifyReturn(1,userIds);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_023() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证userIds-userIds总数大于优惠券");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(1);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(22);
			bean.setCreaterName("autoTest");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();
			
			Logger.verifyEquals(0, call.getTaskId(), "验证返回的TaskId=0");
			Logger.verifyEquals(true, call.getErrorMessage().contains("优惠券数量不足"), "验证errorMessage");
			Logger.verifyEquals(2, call.getErrorCode1(), "验证errorcode");
			Logger.verifyEquals(true, call.getMessage().contains("优惠券数量不足"), "验证message");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_003() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证userIds-集合总数大于100");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(200);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId2.txt");
			List<String> userIds= readFile("userId2.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(22);
			bean.setCreaterName("autoTest");
			bean.setNotify(false);
			bean.setUserQuantity(105);
			call.setData(bean);
			call.callService();	
			verifyReturn(1,userIds);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_028() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证userIds-集合总数等于1000");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(2000);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId3.txt");
			List<String> userIds= readFile("userId3.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(22);
			bean.setCreaterName("autoTest");
			bean.setNotify(false);
			bean.setUserQuantity(107);
			call.setData(bean);
			call.callService();	
			verifyReturn(1,userIds);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_029() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证userIds-集合总数大于1000");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(2000);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId4.txt");
			List<String> userIds= readFile("userId4.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(22);
			bean.setCreaterName("autoTest");
			bean.setNotify(false);
			bean.setUserQuantity(1004);
			call.setData(bean);
			call.callService();	
			verifyReturn(1,userIds);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	@Ignore
	public void Ts_createTaskByUserId_005() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证userIds-包含不存在的用户Id");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(10);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();

			verifyReturn(1,userIds);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_createTaskByUserId_006() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证batchType=1(普通批次)");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(5);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();

			verifyReturn(1,userIds);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_createTaskByUserId_007() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证batchType=2(套券)");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateBagBean createBagBean = couponCallService.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = couponCallService.createPlatformCouponBag(createBagBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(2);
			bean.setBatchCode(createBagCall.getbagCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();

			verifyReturn(1,userIds);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_createTaskByUserId_008() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证batchType不存在");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(5);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(4);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();

			Logger.verifyEquals(true, call.getErrorMessage().contains("batchType:批次类型必须是1或2，1：普通批次，2：套券"), "验证errorMessage");
			Logger.verifyEquals(1, call.getErrorCode1(), "验证errorcode");
			Logger.verifyEquals(true, call.getMessage().contains("batchType:批次类型必须是1或2，1：普通批次，2：套券"), "验证message");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_009() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证batchCode-普通批次batchCode不存在");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(5);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode()+"222");
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();
		
			
			Logger.verifyEquals(true, call.getErrorMessage().contains("批次不存在"), "验证errorMessage");
			Logger.verifyEquals(2, call.getErrorCode1(), "验证errorcode");
			Logger.verifyEquals(true, call.getMessage().contains("批次不存在"), "验证message");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_010() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证batchCode-普通批次batchCode为空");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);

			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();
		
			
			Logger.verifyEquals(true, call.getErrorMessage().contains("必须传入批次编号"), "验证errorMessage");
			Logger.verifyEquals(1, call.getErrorCode1(), "验证errorcode");
			Logger.verifyEquals(true, call.getMessage().contains("必须传入批次编号"), "验证message");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_011() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证batchCode-套券批次batchCode不存在");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateBagBean createBagBean = couponCallService.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = couponCallService.createPlatformCouponBag(createBagBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(2);
			bean.setBatchCode(createBagCall.getbagCode()+"2222");
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();
			
			Logger.verifyEquals(true, call.getErrorMessage().contains("套券批次不存在"), "验证errorMessage");
			Logger.verifyEquals(2, call.getErrorCode1(), "验证errorcode");
			Logger.verifyEquals(true, call.getMessage().contains("套券批次不存在"), "验证message");					
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_012() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证batchCode-套券批次batchCode为空");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(2);
			bean.setBatchCode("");
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals(true, call.getErrorMessage().contains("必须传入批次编号"), "验证errorMessage");
			Logger.verifyEquals(1, call.getErrorCode1(), "验证errorcode");
			Logger.verifyEquals(true, call.getMessage().contains("必须传入批次编号"), "验证message");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_013() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证batchCode-套券批次中含有无效子任务");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateBagBean createBagBean = couponCallService.setDefaultPlatformCreateCouponBagBeanForRecieve();
			List<BatchInfo> BatchInfos=new ArrayList<BatchInfo>();
			BatchInfo info=new BatchInfo();
			info.setCouponName("自动化创建套券优惠券名称-子套券");
			info.setCouponDes("自动化创建套券优惠券描述-子套券");
			info.setApplyMemo("自动化创建申请理由-子套券");
			info.setOrderMinAmount(new BigDecimal(2));
			info.setDeductionMaxAmount(new BigDecimal(1));
			List<String> productIds = new ArrayList<String>();
			info.setProductIds(productIds);
			List<Integer> SellerIds = new ArrayList<Integer>();
			info.setSellerIds(SellerIds);
			List<Integer> ActivityIds = new ArrayList<Integer>();
			info.setActivityIds(ActivityIds);
			List<Integer> Brands = new ArrayList<Integer>();
			info.setBrands(Brands);
			List<Integer> Countrys = new ArrayList<Integer>();
			info.setCountrys(Countrys);
			List<Integer> Categories = new ArrayList<Integer>();
			info.setCategories(Categories);
			info.setLimitPspProduct(false);
			BatchInfos.add(info);
			
			BatchInfo info1=new BatchInfo();
			info1.setCouponName("自动化创建套券优惠券名称-子套券1");
			info1.setCouponDes("自动化创建套券优惠券描述-子套券1");
			info1.setApplyMemo("自动化创建申请理由-子套券1");
			info1.setOrderMinAmount(new BigDecimal(2));
			info1.setDeductionMaxAmount(new BigDecimal(1));
			List<String> productIds1 = new ArrayList<String>();
			info1.setProductIds(productIds1);
			List<Integer> SellerIds1 = new ArrayList<Integer>();
			info1.setSellerIds(SellerIds1);
			List<Integer> ActivityIds1 = new ArrayList<Integer>();
			info1.setActivityIds(ActivityIds1);
			List<Integer> Brands1 = new ArrayList<Integer>();
			info1.setBrands(Brands1);
			List<Integer> Countrys1 = new ArrayList<Integer>();
			info1.setCountrys(Countrys1);
			List<Integer> Categories1 = new ArrayList<Integer>();
			info1.setCategories(Categories1);
			info1.setLimitPspProduct(false);
			BatchInfos.add(info1);
			
			createBagBean.setBatchInfos(BatchInfos);	
			CreateBagCall createBagCall = couponCallService.createPlatformCouponBag(createBagBean);
			
			couponbatch couponbatch=new couponbatchWapper().getCouponBatchByBagCode(createBagCall.getbagCode()).get(0);
			new couponbatchWapper().setIsInvalid(couponbatch.getBatchCode());

			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(2);
			bean.setBatchCode(createBagCall.getbagCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();		
			
			verifyReturn(4,userIds);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_025() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证batchCode-套券批次有两个批次");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateBagBean createBagBean = couponCallService.setDefaultPlatformCreateCouponBagBeanForRecieve();
			List<BatchInfo> BatchInfos=new ArrayList<BatchInfo>();
			BatchInfo info=new BatchInfo();
			info.setCouponName("自动化创建套券优惠券名称-子套券");
			info.setCouponDes("自动化创建套券优惠券描述-子套券");
			info.setApplyMemo("自动化创建申请理由-子套券");
			info.setOrderMinAmount(new BigDecimal(2));
			info.setDeductionMaxAmount(new BigDecimal(1));
			List<String> productIds = new ArrayList<String>();
			info.setProductIds(productIds);
			List<Integer> SellerIds = new ArrayList<Integer>();
			info.setSellerIds(SellerIds);
			List<Integer> ActivityIds = new ArrayList<Integer>();
			info.setActivityIds(ActivityIds);
			List<Integer> Brands = new ArrayList<Integer>();
			info.setBrands(Brands);
			List<Integer> Countrys = new ArrayList<Integer>();
			info.setCountrys(Countrys);
			List<Integer> Categories = new ArrayList<Integer>();
			info.setCategories(Categories);
			info.setLimitPspProduct(false);
			BatchInfos.add(info);
			
			BatchInfo info1=new BatchInfo();
			info1.setCouponName("自动化创建套券优惠券名称-子套券1");
			info1.setCouponDes("自动化创建套券优惠券描述-子套券1");
			info1.setApplyMemo("自动化创建申请理由-子套券1");
			info1.setOrderMinAmount(new BigDecimal(2));
			info1.setDeductionMaxAmount(new BigDecimal(1));
			List<String> productIds1 = new ArrayList<String>();
			info1.setProductIds(productIds1);
			List<Integer> SellerIds1 = new ArrayList<Integer>();
			info1.setSellerIds(SellerIds1);
			List<Integer> ActivityIds1 = new ArrayList<Integer>();
			info1.setActivityIds(ActivityIds1);
			List<Integer> Brands1 = new ArrayList<Integer>();
			info1.setBrands(Brands1);
			List<Integer> Countrys1 = new ArrayList<Integer>();
			info1.setCountrys(Countrys1);
			List<Integer> Categories1 = new ArrayList<Integer>();
			info1.setCategories(Categories1);
			info1.setLimitPspProduct(false);
			BatchInfos.add(info1);
			
			createBagBean.setBatchInfos(BatchInfos);	
			CreateBagCall createBagCall = couponCallService.createPlatformCouponBag(createBagBean);

			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(2);
			bean.setBatchCode(createBagCall.getbagCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();		
			
			verifyReturn(4,userIds);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_014() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证batchCode-套券批次中都是无效子任务");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateBagBean createBagBean = couponCallService.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = couponCallService.createPlatformCouponBag(createBagBean);
	
			couponbatch couponbatch=new couponbatchWapper().getCouponBatchByBagCode(createBagCall.getbagCode()).get(0);
			new couponbatchWapper().setIsInvalid(couponbatch.getBatchCode());
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(2);
			bean.setBatchCode(createBagCall.getbagCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();		
			
			verifyReturn(4,userIds);	

			Logger.verifyEquals(true, call.getErrorMessage().contains("套券中没有有效的子批次"), "验证errorMessage");
			Logger.verifyEquals(2, call.getErrorCode1(), "验证errorcode");
			Logger.verifyEquals(true, call.getMessage().contains("套券中没有有效的子批次"), "验证message");				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_016() {
		Logger.start(true,"根据用户Id列表创建发券任务-notify=false-不通知用户");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(5);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();		
			
			verifyReturn(1,userIds);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_017() {
		Logger.start(true,"根据用户Id列表创建发券任务-notify=true-通知用户");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(5);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(true);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();		
			
			verifyReturn(1,userIds);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_018() {
		Logger.start(true,"根据用户Id列表创建发券任务-FileUrl为空");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(5);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);

			bean.setFileUrl(null);
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(false);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();		
			
			
			Logger.verifyEquals(true, call.getErrorMessage().contains("必须传入文件UR"), "验证errorMessage");
			Logger.verifyEquals(1, call.getErrorCode1(), "验证errorcode");
			Logger.verifyEquals(true, call.getMessage().contains("必须传入文件UR"), "验证message");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_019() {
		Logger.start(true,"根据用户Id列表创建发券任务-batchType为空");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(5);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			//bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(true);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();	
			
			Logger.verifyEquals(true, call.getErrorMessage().contains("批次类型必须是1或2，1：普通批次，2：套券"), "验证errorMessage");
			Logger.verifyEquals(1, call.getErrorCode1(), "验证errorcode");
			Logger.verifyEquals(true, call.getMessage().contains("批次类型必须是1或2，1：普通批次，2：套券"), "验证message");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_021() {
		Logger.start(true,"根据用户Id列表创建发券任务-createrName为空");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(5);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(11);
			bean.setCreaterName("");
			bean.setNotify(true);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();	
			
			Logger.verifyEquals(true, call.getErrorMessage().contains("必须传入创建者姓名"), "验证errorMessage");
			Logger.verifyEquals(1, call.getErrorCode1(), "验证errorcode");
			Logger.verifyEquals(true, call.getMessage().contains("必须传入创建者姓名"), "验证message");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_createTaskByUserId_022() {
		Logger.start(true,"根据用户Id列表创建发券任务-notify为空");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setCouponNum(5);
			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(1);
			bean.setBatchCode(createCouponCall.getBatchCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			//bean.setNotify(true);
			bean.setUserQuantity(3);
			call.setData(bean);
			call.callService();	
			
			verifyReturn(1,userIds);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_createTaskByUserId_024() {
		Logger.start(true,"根据用户Id列表创建发券任务-验证一个套券有21个批次");
		try {
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CreateBagBean createBagBean = couponCallService.setDefaultPlatformCreateCouponBagBeanForRecieve();
			createBagBean.setTotalNum(30000);
			List<BatchInfo> BatchInfos=new ArrayList<BatchInfo>();
			BatchInfo info=new BatchInfo();
			info.setCouponName("自动化创建套券优惠券名称-子套券");
			info.setCouponDes("自动化创建套券优惠券描述-子套券");
			info.setApplyMemo("自动化创建申请理由-子套券");
			info.setOrderMinAmount(new BigDecimal(2));
			info.setDeductionMaxAmount(new BigDecimal(1));
			List<String> productIds = new ArrayList<String>();
			info.setProductIds(productIds);
			List<Integer> SellerIds = new ArrayList<Integer>();
			info.setSellerIds(SellerIds);
			List<Integer> ActivityIds = new ArrayList<Integer>();
			info.setActivityIds(ActivityIds);
			List<Integer> Brands = new ArrayList<Integer>();
			info.setBrands(Brands);
			List<Integer> Countrys = new ArrayList<Integer>();
			info.setCountrys(Countrys);
			List<Integer> Categories = new ArrayList<Integer>();
			info.setCategories(Categories);
			info.setLimitPspProduct(false);
			for(int i=0;i<20;i++)
			{
			 BatchInfos.add(info);
			}
			createBagBean.setBatchInfos(BatchInfos);	
			CreateBagCall createBagCall = couponCallService.createPlatformCouponBag(createBagBean);
			
			UploadCall uploadcall=couponCallService.fileUpload("userId1.txt");
			List<String> userIds= readFile("userId1.txt");
			bean.setFileUrl(uploadcall.getFileUrl());
			bean.setBatchType(2);
			bean.setBatchCode(createBagCall.getbagCode());
			bean.setCreaterId(11);
			bean.setCreaterName("自动化测试");
			bean.setNotify(true);
			bean.setUserQuantity(userIds.size());
			call.setData(bean);
			call.callService();	
			
			Logger.verifyEquals("null", call.getErrorMessage(), "验证errorMessage");
			Logger.verifyEquals(0, call.getErrorCode1(), "验证errorcode");
			Logger.verifyEquals("操作成功！", call.getMessage(), "验证message");
			//couponsendtask
			couponsendtask couponsendtask=new couponsendtaskWapper().selectByCouponBatchCode(bean.getBatchCode()).get(0);
			Logger.verifyEquals(couponsendtask.getTaskId(), call.getTaskId(), "验证数据库couponsendtask表中的TaskId与返回的TaskId是否一致");
			Logger.verifyEquals(bean.getUserQuantity(), couponsendtask.getTotalNum(), "验证数据库couponsendtask表中的TotalNum");
			Logger.verifyEquals(userIds.size(), couponsendtask.getSuccessNum(), "验证数据库couponsendtask表中的SuccessNum");
			Logger.verifyEquals(0, couponsendtask.getFailNum(), "验证数据库couponsendtask表中的FailNum");
			Logger.verifyEquals(2, couponsendtask.getStatus(), "验证数据库couponsendtask表中的Status");
			Logger.verifyEquals(4, couponsendtask.getTaskType(), "验证数据库couponsendtask表中的TaskType");
			Logger.verifyEquals(bean.getNotify(), couponsendtask.getIsNotify(), "验证数据库couponsendtask表中的Notify");
			//验证couponsendsubtask
			List<couponsendsubtask> couponsendsubtask=new couponsendsubtaskWapper().selectcouponsendsubtaskByTaskId(couponsendtask.getTaskId());
			int subTaskQuantity=0;
			int subTaskPerUser=100/createBagBean.getBatchInfos().size(); //每个子任务发放用户数量 = 每次发放券数 / 批次数
		    if (userIds.size() % subTaskPerUser == 0) {
		    	subTaskQuantity= userIds.size() / subTaskPerUser;
			  } else {
				  subTaskQuantity= userIds.size() / subTaskPerUser + 1;
			  }
		    for (int i = 0; i < subTaskQuantity; i++) {
			     int count=i+1;
			     int TotalNumPersubTask=calcGenerateQuantity(subTaskQuantity,count,subTaskPerUser,userIds.size());//每个Task的userId数量
			     Logger.verifyEquals(SubBagString(userIds,TotalNumPersubTask,i,subTaskPerUser),couponsendsubtask.get(i).getUserIds() , "验证数据库couponsendsubtask表第"+count+"个子任务中的UserIds字段");
			     Logger.verifyEquals(TotalNumPersubTask,couponsendsubtask.get(i).getTotalNum() , "验证数据库couponsendsubtask表第"+count+"个子任务中的TotalNum字段");
			     Logger.verifyEquals(TotalNumPersubTask,couponsendsubtask.get(i).getSuccessNum() , "验证数据库couponsendsubtask表第"+count+"个子任务中的SuccessNum字段");
			     Logger.verifyEquals(0,couponsendsubtask.get(i).getFailNum() , "验证数据库couponsendsubtask表第"+count+"个子任务中的FailNum字段");
		    }
			Logger.verifyEquals(subTaskQuantity, couponsendsubtask.size(), "验证TaskId="+couponsendtask.getTaskId()+" 的子任务couponsendsubtask数量");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
//	@Test
//	@Category({P2.class})
//	@TestCase
//	public void Ts_createTaskByUserId_030() {
//		Logger.start(true,"根据用户Id列表创建发券任务-验证套券发放用户超过1000");
//		try {
//			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
//			CreateBagBean createBagBean = couponCallService.setDefaultPlatformCreateCouponBagBeanForRecieve();
//			createBagBean.setTotalNum(3000);
//			List<BatchInfo> BatchInfos=new ArrayList<BatchInfo>();
//			BatchInfo info=new BatchInfo();
//			info.setCouponName("自动化创建套券优惠券名称-子套券");
//			info.setCouponDes("自动化创建套券优惠券描述-子套券");
//			info.setApplyMemo("自动化创建申请理由-子套券");
//			info.setOrderMinAmount(new BigDecimal(2));
//			info.setDeductionMaxAmount(new BigDecimal(1));
//			List<String> productIds = new ArrayList<String>();
//			info.setProductIds(productIds);
//			List<Integer> SellerIds = new ArrayList<Integer>();
//			info.setSellerIds(SellerIds);
//			List<Integer> ActivityIds = new ArrayList<Integer>();
//			info.setActivityIds(ActivityIds);
//			List<Integer> Brands = new ArrayList<Integer>();
//			info.setBrands(Brands);
//			List<Integer> Countrys = new ArrayList<Integer>();
//			info.setCountrys(Countrys);
//			List<Integer> Categories = new ArrayList<Integer>();
//			info.setCategories(Categories);
//			info.setLimitPspProduct(false);
//			for(int i=0;i<100;i++)
//			{
//			 BatchInfos.add(info);
//			}
//			createBagBean.setBatchInfos(BatchInfos);	
//			CreateBagCall createBagCall = couponCallService.createPlatformCouponBag(createBagBean);
//
//			
//			UploadCall uploadcall=couponCallService.fileUpload("userId4.txt");
//			List<String> userIds= readFile("userId4.txt");
//			bean.setFileUrl(uploadcall.getFileUrl());
//			bean.setBatchType(2);
//			bean.setBatchCode(createBagCall.getbagCode());
//			bean.setCreaterId(11);
//			bean.setCreaterName("自动化测试");
//			bean.setNotify(true);
//			bean.setUserQuantity(userIds.size());
//			call.setData(bean);
//			call.callService();	
//			
//			Thread.sleep(10000);
//			Logger.verifyEquals("null", call.getErrorMessage(), "验证errorMessage");
//			Logger.verifyEquals(0, call.getErrorCode1(), "验证errorcode");
//			Logger.verifyEquals("操作成功！", call.getMessage(), "验证message");
//			//couponsendtask
//			couponsendtask couponsendtask=new couponsendtaskWapper().selectByCouponBatchCode(bean.getBatchCode()).get(0);
//			Logger.verifyEquals(couponsendtask.getTaskId(), call.getTaskId(), "验证数据库couponsendtask表中的TaskId与返回的TaskId是否一致");
//			Logger.verifyEquals(bean.getUserQuantity(), couponsendtask.getTotalNum(), "验证数据库couponsendtask表中的TotalNum");
//			Logger.verifyEquals(userIds.size(), couponsendtask.getSuccessNum(), "验证数据库couponsendtask表中的SuccessNum");
//			Logger.verifyEquals(0, couponsendtask.getFailNum(), "验证数据库couponsendtask表中的FailNum");
//			Logger.verifyEquals(2, couponsendtask.getStatus(), "验证数据库couponsendtask表中的Status");
//			Logger.verifyEquals(4, couponsendtask.getTaskType(), "验证数据库couponsendtask表中的TaskType");
//			Logger.verifyEquals(bean.getNotify(), couponsendtask.getIsNotify(), "验证数据库couponsendtask表中的Notify");
//			//验证couponsendsubtask
//			List<couponsendsubtask> couponsendsubtask=new couponsendsubtaskWapper().selectcouponsendsubtaskByTaskId(couponsendtask.getTaskId());
//			int subTaskQuantity=0;
//			int subTaskPerUser=100/createBagBean.getBatchInfos().size(); //每个子任务发放用户数量 = 每次发放券数 / 批次数
//		    if (userIds.size() % subTaskPerUser == 0) {
//		    	subTaskQuantity= userIds.size() / subTaskPerUser;
//			  } else {
//				  subTaskQuantity= userIds.size() / subTaskPerUser + 1;
//			  }
//		    for (int i = 0; i < subTaskQuantity; i++) {
//			     int count=i+1;
//			     int TotalNumPersubTask=calcGenerateQuantity(subTaskQuantity,count,subTaskPerUser,userIds.size());//每个Task的userId数量
//			     Logger.verifyEquals(SubBagString(userIds,TotalNumPersubTask,i,subTaskPerUser),couponsendsubtask.get(i).getUserIds() , "验证数据库couponsendsubtask表第"+count+"个子任务中的UserIds字段");
//			     Logger.verifyEquals(TotalNumPersubTask,couponsendsubtask.get(i).getTotalNum() , "验证数据库couponsendsubtask表第"+count+"个子任务中的TotalNum字段");
//			     Logger.verifyEquals(TotalNumPersubTask,couponsendsubtask.get(i).getSuccessNum() , "验证数据库couponsendsubtask表第"+count+"个子任务中的SuccessNum字段");
//			     Logger.verifyEquals(0,couponsendsubtask.get(i).getFailNum() , "验证数据库couponsendsubtask表第"+count+"个子任务中的FailNum字段");
//		    }
//			Logger.verifyEquals(subTaskQuantity, couponsendsubtask.size(), "验证TaskId="+couponsendtask.getTaskId()+" 的子任务couponsendsubtask数量");
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}
	private void verifyReturn(Integer taskType,List<String> userIds) throws InterruptedException
	{
		Thread.sleep(5000);
		Logger.verifyEquals("null", call.getErrorMessage(), "验证errorMessage");
		Logger.verifyEquals(0, call.getErrorCode1(), "验证errorcode");
		Logger.verifyEquals("操作成功！", call.getMessage(), "验证message");
		int taskId=checkcouponsendtask(taskType,userIds);
		couponsendsubtask(taskId,userIds);
		
	}
	private int checkcouponsendtask(Integer taskType,List<String> userIds)
	{
		couponsendtask couponsendtask=new couponsendtaskWapper().selectByCouponBatchCode(bean.getBatchCode()).get(0);
		Logger.verifyEquals(couponsendtask.getTaskId(), call.getTaskId(), "验证数据库couponsendtask表中的TaskId与返回的TaskId是否一致");
		Logger.verifyEquals(bean.getUserQuantity(), couponsendtask.getTotalNum(), "验证数据库couponsendtask表中的TotalNum");
		Logger.verifyEquals(userIds.size(), couponsendtask.getSuccessNum(), "验证数据库couponsendtask表中的SuccessNum");
//		Logger.verifyEquals(0, couponsendtask.getFailNum(), "验证数据库couponsendtask表中的FailNum");
//		Logger.verifyEquals(2, couponsendtask.getStatus(), "验证数据库couponsendtask表中的Status");
		Logger.verifyEquals(taskType, couponsendtask.getTaskType(), "验证数据库couponsendtask表中的TaskType");
		Logger.verifyEquals(bean.getNotify(), couponsendtask.getIsNotify(), "验证数据库couponsendtask表中的Notify");
		return couponsendtask.getTaskId();
	}
	private void couponsendsubtask(Integer taskId,List<String> userIds)
	{
		List<couponsendsubtask> couponsendsubtask=new couponsendsubtaskWapper().selectcouponsendsubtaskByTaskId(taskId);
		int subTaskQuantity=0;// 子任务个数   //每个子任务发放用户数量 = 每次发放券数 / 批次数
	    if (userIds.size() % 100 == 0) {
	    	subTaskQuantity= userIds.size() / 100;
		  } else {
			  subTaskQuantity= userIds.size() / 100 + 1;
		  }
	    for (int i = 0; i < subTaskQuantity; i++) {
		     int count=i+1;
		     int TotalNumPersubTask=calcGenerateQuantity(subTaskQuantity,count,100,userIds.size());//每个Task的userId数量
		     Logger.verifyEquals(SubString(userIds,TotalNumPersubTask,i),couponsendsubtask.get(i).getUserIds() , "验证数据库couponsendsubtask表第"+count+"个子任务中的UserIds字段");
		     Logger.verifyEquals(TotalNumPersubTask,couponsendsubtask.get(i).getTotalNum() , "验证数据库couponsendsubtask表第"+count+"个子任务中的TotalNum字段");
		     Logger.verifyEquals(TotalNumPersubTask,couponsendsubtask.get(i).getSuccessNum() , "验证数据库couponsendsubtask表第"+count+"个子任务中的SuccessNum字段");
		     Logger.verifyEquals(0,couponsendsubtask.get(i).getFailNum() , "验证数据库couponsendsubtask表第"+count+"个子任务中的FailNum字段");
	    }
		Logger.verifyEquals(subTaskQuantity, couponsendsubtask.size(), "验证TaskId="+taskId+" 的子任务couponsendsubtask数量");
	}
	/**
	 * 
	 * @param totalSubTaskQuantity 子任务个数
	 * @param currentSubTaskNum 当前第几个子任务
	 * @param generateQuantityPerSubTask 每个子任务做多可以发放多少个用户，目前是100
	 * @param totalGenerateQuantity 总用户数
	 * @return
	 */
    private int calcGenerateQuantity(int totalSubTaskQuantity, int currentSubTaskNum, int generateQuantityPerSubTask, int totalGenerateQuantity) {
        if (currentSubTaskNum < totalSubTaskQuantity) {
            return generateQuantityPerSubTask;
        } else {
            return totalGenerateQuantity - ((totalSubTaskQuantity - 1) * generateQuantityPerSubTask);
        }
    }
    /**
     * 用于普通优惠券
     * @param userIds
     * @param TotalNumPersubTask
     * @param currentSubTaskNum
     * @return
     */
    private String SubString(List<String> userIds,int TotalNumPersubTask,int currentSubTaskNum){
    	//return StringUtils.join(userIds.toArray(), ",") ;
    	String userIdStr="";
    	if(currentSubTaskNum==0 && TotalNumPersubTask<=100)
    	{
        	for(int i=0;i<TotalNumPersubTask;i++)
        	{
        		userIdStr+=userIds.get(i)+",";
        	}
    	}
    	else
    	{
    		int total=currentSubTaskNum*TotalNumPersubTask;
    		if(total<100)
    		{
	    		for(int i=(userIds.size()-total);i<userIds.size();i++)
	        	{
	        		userIdStr+=userIds.get(i)+",";
	        	}
    		}
    		else
    		{
    			for(int i=total;i<((currentSubTaskNum+1)*TotalNumPersubTask);i++)
	        	{
	        		userIdStr+=userIds.get(i)+",";
	        	}
    		}
    	}
    	return userIdStr.substring(0, userIdStr.length()-1);
    }
    
    /**
     * 用于套券
     * @param userIds
     * @param TotalNumPersubTask
     * @param currentSubTaskNum
     * @return
     */
    private String SubBagString(List<String> userIds,int TotalNumPersubTask,int currentSubTaskNum,int subTaskQuantity){
    	//return StringUtils.join(userIds.toArray(), ",") ;
    	String userIdStr="";
    	if(currentSubTaskNum==0 && TotalNumPersubTask<=subTaskQuantity)
    	{
        	for(int i=0;i<TotalNumPersubTask;i++)
        	{
        		userIdStr+=userIds.get(i)+",";
        	}
    	}
    	else
    	{
    		int total=currentSubTaskNum*TotalNumPersubTask;
    		if(total<subTaskQuantity)
    		{
	    		for(int i=(userIds.size()-total);i<userIds.size();i++)
	        	{
	        		userIdStr+=userIds.get(i)+",";
	        	}
    		}
    		else
    		{
    			for(int i=total;i<((currentSubTaskNum+1)*TotalNumPersubTask);i++)
	        	{
	        		userIdStr+=userIds.get(i)+",";
	        	}
    		}
    	}
    	return userIdStr.substring(0, userIdStr.length()-1);
    }
    
    protected List<String> readFile(String pathName)
    {
      List<String> userIds=new ArrayList();
	  try { // 防止文件建立或读取失败，用catch捕捉错误并打印，也可以throw  

          /* 读入TXT文件 */  
          String pathname = "E:\\workSpaceTemp\\YmatouTest\\resource\\Coupon\\"+pathName+""; // 绝对路径或相对路径都可以，这里是绝对路径，写入文件时演示相对路径  
          FileReader reader = new FileReader(pathname);//定义一个fileReader对象，用来初始化BufferedReader
          BufferedReader bReader = new BufferedReader(reader);//new一个BufferedReader对象，将文件内容读取到缓存
          StringBuilder sb = new StringBuilder();//定义一个字符串缓存，将字符串存放缓存中
          String s = "";

          while ((s =bReader.readLine()) != null) {//逐行读取文件内容，不读取换行符和末尾的空格
        	  userIds.add(s);
          }
          bReader.close();
      } catch (Exception e) {  
          e.printStackTrace();  
      }  
	  userIds.remove(0);
      return userIds;
    }
    
}